#ifndef __RT_BINDHELPER_H__
#define __RT_BINDHELPER_H__

#include "RtDefines.h"
#include "RtReferenceControl.h"
#include "RtMessageBlock.h"


template <class T> class CRtBindAutoPtrWrapper
{
public:	
	CRtBindAutoPtrWrapper(T *aPtr) 
	{
		m_autoPtr = aPtr;
	}
	~CRtBindAutoPtrWrapper()
	{ }
	operator T*()
	{
		return m_autoPtr.Get();
	}
private:
	CRtAutoPtr<T> m_autoPtr;
};

class CRtBindMessageBlockWrapper
{
public:	
	CRtBindMessageBlockWrapper(CRtMessageBlock* aData)
		: m_data(NULL) 
	{ 
		if (aData) 
			m_data = aData->DuplicateChained(); 
	}
	CRtBindMessageBlockWrapper(const CRtBindMessageBlockWrapper& aRight)
		: m_data(NULL) 
	{
		if (aRight.m_data)
		{ m_data = aRight.m_data->DuplicateChained(); }
	}
	~CRtBindMessageBlockWrapper()
	{
		if (m_data)
			m_data->DestroyChained();
	}
	operator CRtMessageBlock*()
	{ return m_data; }
private:
	CRtMessageBlock* m_data;
};

#endif //!__RT_BINDHELPER_H__
